package com.itheima.service.imp;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.dao.RepositoryDao;
import com.itheima.pojo.Exercise;
import com.itheima.pojo.Repository;
import com.itheima.service.RepositoryService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class RepositoryServiceImp implements RepositoryService {
   @Autowired
    private RepositoryDao repositoryDao;
    @Override
    public void add(List<Repository> repositories) {
        if(repositories!=null&&repositories.size()>0){
            for (Repository repository : repositories) {
                repositoryDao.add(repository);
            }

        }
    }

    @Override
    public void addExercise(List<Exercise> exercises) {
        if(exercises!=null&&exercises.size()>0){
            for (Exercise exercise : exercises) {
                repositoryDao.addExercise(exercise);
            }

        }
    }

    @Override
    public List<Repository> find() {

        return repositoryDao.find();
    }
}
